package web.JavaDate;

import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;

import java.time.*;
import java.time.format.DateTimeFormatter;
import java.time.format.FormatStyle;
import java.time.temporal.ChronoUnit;
import java.util.Locale;
import java.util.Set;

/**
 * description:
 * author:zcx
 * lenovo
 * 时间：2022.02.10.14.52
 */
public class D3 {
    @Test
    @DisplayName("LocalDate")
    public void m2() {
        LocalDate today=LocalDate.now();
        LocalDate tomorrow=today.plus(1, ChronoUnit.DAYS);
        LocalDate yesterday=tomorrow.minusDays(2);
        System.out.println(yesterday);
        LocalDate independenceDay=LocalDate.of(2022, Month.JULY,4);
        DayOfWeek dayOfWeek=independenceDay.getDayOfWeek();
        System.out.println(dayOfWeek);
        DateTimeFormatter germanFormatter=DateTimeFormatter.ofLocalizedDate(FormatStyle.MEDIUM).withLocale(Locale.GERMAN);
    }
    @Test
    @DisplayName("LocalTime")
    public void m1(){
    Set<String> avaZoneIds= ZoneId.getAvailableZoneIds();
        System.out.println(avaZoneIds);
        //获取当前时间
        ZoneId zoneId=ZoneId.of("Asia/Shanghai");
        LocalTime localTime=LocalTime.now(zoneId);
        System.out.println("localTime:"+localTime);
        //获取定时时间
        LocalTime localTime1=LocalTime.of(15,01,33);
        System.out.println("localTime:"+localTime1+localTime1.getHour()+localTime1.getMinute()+localTime1.getSecond());
        //获取两个时间的时间差（时间小的第一个参数结果是负数）

    }
}
